#include <iostream>
#include <ostream>
#include <fstream>
#include <ctime>
using namespace std;

const int MAX = 100;
int matrix[MAX][MAX] = {0};
int n;
int *pointer;

int main()
{
//    ifstream fin("data.txt");
//    streambuf  *cinbackup;
//    cinbackup = cin.rdbuf(fin.rdbuf());
//    cin.rdbuf(cinbackup);
//    cin >> n;
    n = 100;
    srand((unsigned)time(0));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < n - i; ++j) {
//            cin >> matrix[i][j];
            matrix[i][j] = rand() % 100;
        }
    }
#define DEBUG_
#ifdef DEBUG_
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < n - i; ++j) {
            cout << matrix[i][j] << " ";
        }
        cout << "\n";
    }
#endif
    pointer = matrix[n-1];
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < n - i; ++j) {
            pointer[j] = std::max(pointer[j],pointer[j+1])+matrix[i][j];
        }
    }
    cout << "max value is: " << pointer[0] << endl;

    return 0;
}

